<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: include/hardware/adc.h Source File</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.0.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('rp2__common_2hardware__adc_2include_2hardware_2adc_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">adc.h</div></div>
</div><!--header-->
<div class="contents">
<a href="rp2__common_2hardware__adc_2include_2hardware_2adc_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> */</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#ifndef _HARDWARE_ADC_H</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#define _HARDWARE_ADC_H</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;<a class="code" href="pico_8h.html">pico.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#include &quot;hardware/structs/adc.h&quot;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="preprocessor">#include &quot;<a class="code" href="gpio_8h.html">hardware/gpio.h</a>&quot;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span><span class="comment">// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_ADC, Enable/disable assertions in the hardware_adc module, type=bool, default=0, group=hardware_adc</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span><span class="preprocessor">#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_ADC</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span><span class="preprocessor">#ifdef PARAM_ASSERTIONS_ENABLED_ADC </span><span class="comment">// backwards compatibility with SDK &lt; 2.0.0</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span><span class="preprocessor">#define PARAM_ASSERTIONS_ENABLED_HARDWARE_ADC PARAM_ASSERTIONS_ENABLED_ADC</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span><span class="preprocessor">#define PARAM_ASSERTIONS_ENABLED_HARDWARE_ADC 0</span></div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span> </div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span><span class="preprocessor">#ifndef ADC_TEMPERATURE_CHANNEL_NUM</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="rp2__common_2hardware__adc_2include_2hardware_2adc_8h.html#a9622105dbe8b3d37a5118dab13c551e9">   70</a></span><span class="preprocessor">#define ADC_TEMPERATURE_CHANNEL_NUM (NUM_ADC_CHANNELS - 1)</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span> </div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span> </div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga2b815e6730e8723a6d1d06d9ef8f31c0">adc_init</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span> </div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">   90</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">adc_gpio_init</a>(uint gpio) {</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>    invalid_params_if(HARDWARE_ADC, gpio &lt; ADC_BASE_PIN || gpio &gt;= ADC_BASE_PIN + NUM_ADC_CHANNELS - 1);</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>    <span class="comment">// Select NULL function to make output driver hi-Z</span></div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>    <a class="code hl_function" href="group__hardware__gpio.html#ga22f6b90c4c7e0013b4b5341de0a44fc4">gpio_set_function</a>(gpio, <a class="code hl_enumvalue" href="group__hardware__gpio.html#ggaf91b38a4d4e96c343bd16927c34936e0a3ec115257e1f1747abf60284362c5a04">GPIO_FUNC_NULL</a>);</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    <span class="comment">// Also disable digital pulls and digital receiver</span></div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>    <a class="code hl_function" href="group__hardware__gpio.html#gae57a625b7e0bcac6d596f35864ffc792">gpio_disable_pulls</a>(gpio);</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>    <a class="code hl_function" href="group__hardware__gpio.html#ga74a8c3e55185581bc3df335aea1d0fb8">gpio_set_input_enabled</a>(gpio, <span class="keyword">false</span>);</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>}</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">  113</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">adc_select_input</a>(uint input) {</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>    valid_params_if(HARDWARE_ADC, input &lt; NUM_ADC_CHANNELS);</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>    <a class="code hl_function" href="group__hardware__base.html#ga81b27e30abef56fe090d22fd8dfdbcc1">hw_write_masked</a>(&amp;adc_hw-&gt;cs, input &lt;&lt; ADC_CS_AINSEL_LSB, ADC_CS_AINSEL_BITS);</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>}</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span> </div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga84b5f9054de9c00d51095c9bdefb2dca">  132</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint <a class="code hl_function" href="group__hardware__adc.html#ga84b5f9054de9c00d51095c9bdefb2dca">adc_get_selected_input</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>    <span class="keywordflow">return</span> (adc_hw-&gt;cs &amp; ADC_CS_AINSEL_BITS) &gt;&gt; ADC_CS_AINSEL_LSB;</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>}</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span> </div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga16d25be75e16f0671d3e3185b0b59771">  145</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga16d25be75e16f0671d3e3185b0b59771">adc_set_round_robin</a>(uint input_mask) {</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>    valid_params_if(HARDWARE_ADC, input_mask &lt; (1 &lt;&lt; NUM_ADC_CHANNELS));</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span>    <a class="code hl_function" href="group__hardware__base.html#ga81b27e30abef56fe090d22fd8dfdbcc1">hw_write_masked</a>(&amp;adc_hw-&gt;cs, input_mask &lt;&lt; ADC_CS_RROBIN_LSB, ADC_CS_RROBIN_BITS);</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span>}</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span> </div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga33f302059e05899d1709d6268d75972b">  156</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga33f302059e05899d1709d6268d75972b">adc_set_temp_sensor_enabled</a>(<span class="keywordtype">bool</span> enable) {</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>    <span class="keywordflow">if</span> (enable)</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>        <a class="code hl_function" href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a>(&amp;adc_hw-&gt;cs, ADC_CS_TS_EN_BITS);</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>    <span class="keywordflow">else</span></div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>        <a class="code hl_function" href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a>(&amp;adc_hw-&gt;cs, ADC_CS_TS_EN_BITS);</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>}</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span> </div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">  170</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint16_t <a class="code hl_function" href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">adc_read</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span>    <a class="code hl_function" href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a>(&amp;adc_hw-&gt;cs, ADC_CS_START_ONCE_BITS);</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span> </div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span>    <span class="keywordflow">while</span> (!(adc_hw-&gt;cs &amp; ADC_CS_READY_BITS))</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span>        <a class="code hl_function" href="group__pico__platform.html#gab0d1ba75ceb64131e19f613d7a5313c9">tight_loop_contents</a>();</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno">  175</span> </div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno">  176</span>    <span class="keywordflow">return</span> (uint16_t) adc_hw-&gt;result;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno">  177</span>}</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno">  178</span> </div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga5d50a24eb26da7fbc6ee9bc76723b09c">  184</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga5d50a24eb26da7fbc6ee9bc76723b09c">adc_run</a>(<span class="keywordtype">bool</span> run) {</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>    <span class="keywordflow">if</span> (run)</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span>        <a class="code hl_function" href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a>(&amp;adc_hw-&gt;cs, ADC_CS_START_MANY_BITS);</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span>    <span class="keywordflow">else</span></div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>        <a class="code hl_function" href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a>(&amp;adc_hw-&gt;cs, ADC_CS_START_MANY_BITS);</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span>}</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span> </div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga333f7ca46a11241d96d0a4c24f0d4bb0">  199</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga333f7ca46a11241d96d0a4c24f0d4bb0">adc_set_clkdiv</a>(<span class="keywordtype">float</span> clkdiv) {</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>    invalid_params_if(HARDWARE_ADC, clkdiv &gt;= 1 &lt;&lt; (ADC_DIV_INT_MSB - ADC_DIV_INT_LSB + 1));</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span>    adc_hw-&gt;div = (uint32_t)(clkdiv * (<span class="keywordtype">float</span>) (1 &lt;&lt; ADC_DIV_INT_LSB));</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span>}</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno">  203</span> </div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga2a6fa32da04e65a027e14deaf32b8f10">  223</a></span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#ga2a6fa32da04e65a027e14deaf32b8f10">adc_fifo_setup</a>(<span class="keywordtype">bool</span> en, <span class="keywordtype">bool</span> dreq_en, uint16_t dreq_thresh, <span class="keywordtype">bool</span> err_in_fifo, <span class="keywordtype">bool</span> byte_shift) {</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno">  224</span>    <a class="code hl_function" href="group__hardware__base.html#ga81b27e30abef56fe090d22fd8dfdbcc1">hw_write_masked</a>(&amp;adc_hw-&gt;fcs,</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span>                   (bool_to_bit(en) &lt;&lt; ADC_FCS_EN_LSB) |</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno">  226</span>                   (bool_to_bit(dreq_en) &lt;&lt; ADC_FCS_DREQ_EN_LSB) |</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno">  227</span>                   (((uint)dreq_thresh) &lt;&lt; ADC_FCS_THRESH_LSB) |</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span>                   (bool_to_bit(err_in_fifo) &lt;&lt; ADC_FCS_ERR_LSB) |</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span>                   (bool_to_bit(byte_shift) &lt;&lt; ADC_FCS_SHIFT_LSB),</div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno">  230</span>                   ADC_FCS_EN_BITS |</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno">  231</span>                   ADC_FCS_DREQ_EN_BITS |</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span>                   ADC_FCS_THRESH_BITS |</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno">  233</span>                   ADC_FCS_ERR_BITS |</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span>                   ADC_FCS_SHIFT_BITS</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span>    );</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span>}</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span> </div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">  243</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">adc_fifo_is_empty</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno">  244</span>    <span class="keywordflow">return</span> adc_hw-&gt;fcs &amp; ADC_FCS_EMPTY_BITS;</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno">  245</span>}</div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno">  246</span> </div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#gafa9793deea59c5cbfea147e0e9d895c3">  259</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint8_t <a class="code hl_function" href="group__hardware__adc.html#gafa9793deea59c5cbfea147e0e9d895c3">adc_fifo_get_level</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>    <span class="keywordflow">return</span> (adc_hw-&gt;fcs &amp; ADC_FCS_LEVEL_BITS) &gt;&gt; ADC_FCS_LEVEL_LSB;</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span>}</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span> </div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga689d64744e7fe5284562569b24e9d624">  268</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint16_t <a class="code hl_function" href="group__hardware__adc.html#ga689d64744e7fe5284562569b24e9d624">adc_fifo_get</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno">  269</span>    <span class="keywordflow">return</span> (uint16_t)adc_hw-&gt;fifo;</div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno">  270</span>}</div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno">  271</span> </div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#ga61553375ecc9275fa14c6ff7792a1506">  277</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint16_t <a class="code hl_function" href="group__hardware__adc.html#ga61553375ecc9275fa14c6ff7792a1506">adc_fifo_get_blocking</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno">  278</span>    <span class="keywordflow">while</span> (<a class="code hl_function" href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">adc_fifo_is_empty</a>())</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span>        <a class="code hl_function" href="group__pico__platform.html#gab0d1ba75ceb64131e19f613d7a5313c9">tight_loop_contents</a>();</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span>    <span class="keywordflow">return</span> (uint16_t)adc_hw-&gt;fifo;</div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno">  281</span>}</div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno">  282</span> </div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#gad637d97583f2c24e4159dc22bf17eaf2">  288</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#gad637d97583f2c24e4159dc22bf17eaf2">adc_fifo_drain</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno">  289</span>    <span class="comment">// Potentially there is still a conversion in progress -- wait for this to complete before draining</span></div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno">  290</span>    <span class="keywordflow">while</span> (!(adc_hw-&gt;cs &amp; ADC_CS_READY_BITS))</div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno">  291</span>        <a class="code hl_function" href="group__pico__platform.html#gab0d1ba75ceb64131e19f613d7a5313c9">tight_loop_contents</a>();</div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno">  292</span>    <span class="keywordflow">while</span> (!<a class="code hl_function" href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">adc_fifo_is_empty</a>())</div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno">  293</span>        (void) <a class="code hl_function" href="group__hardware__adc.html#ga689d64744e7fe5284562569b24e9d624">adc_fifo_get</a>();</div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno">  294</span>}</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno">  295</span> </div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno"><a class="line" href="group__hardware__adc.html#gaf8e363e63f40e00c169f7355c9668681">  301</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__adc.html#gaf8e363e63f40e00c169f7355c9668681">adc_irq_set_enabled</a>(<span class="keywordtype">bool</span> enabled) {</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno">  302</span>    adc_hw-&gt;inte = !!enabled;</div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno">  303</span>}</div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno">  304</span> </div>
<div class="line"><a id="l00305" name="l00305"></a><span class="lineno">  305</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00306" name="l00306"></a><span class="lineno">  306</span>}</div>
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno">  307</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno">  308</span> </div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno">  309</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="agpio_8h_html"><div class="ttname"><a href="gpio_8h.html">gpio.h</a></div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga16d25be75e16f0671d3e3185b0b59771"><div class="ttname"><a href="group__hardware__adc.html#ga16d25be75e16f0671d3e3185b0b59771">adc_set_round_robin</a></div><div class="ttdeci">static void adc_set_round_robin(uint input_mask)</div><div class="ttdoc">Round Robin sampling selector.</div><div class="ttdef"><b>Definition:</b> adc.h:145</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga2a6fa32da04e65a027e14deaf32b8f10"><div class="ttname"><a href="group__hardware__adc.html#ga2a6fa32da04e65a027e14deaf32b8f10">adc_fifo_setup</a></div><div class="ttdeci">static void adc_fifo_setup(bool en, bool dreq_en, uint16_t dreq_thresh, bool err_in_fifo, bool byte_shift)</div><div class="ttdoc">Setup the ADC FIFO.</div><div class="ttdef"><b>Definition:</b> adc.h:223</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga2b815e6730e8723a6d1d06d9ef8f31c0"><div class="ttname"><a href="group__hardware__adc.html#ga2b815e6730e8723a6d1d06d9ef8f31c0">adc_init</a></div><div class="ttdeci">void adc_init(void)</div><div class="ttdoc">Initialise the ADC HW.</div><div class="ttdef"><b>Definition:</b> adc.c:11</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga333f7ca46a11241d96d0a4c24f0d4bb0"><div class="ttname"><a href="group__hardware__adc.html#ga333f7ca46a11241d96d0a4c24f0d4bb0">adc_set_clkdiv</a></div><div class="ttdeci">static void adc_set_clkdiv(float clkdiv)</div><div class="ttdoc">Set the ADC Clock divisor.</div><div class="ttdef"><b>Definition:</b> adc.h:199</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga33f302059e05899d1709d6268d75972b"><div class="ttname"><a href="group__hardware__adc.html#ga33f302059e05899d1709d6268d75972b">adc_set_temp_sensor_enabled</a></div><div class="ttdeci">static void adc_set_temp_sensor_enabled(bool enable)</div><div class="ttdoc">Enable the onboard temperature sensor.</div><div class="ttdef"><b>Definition:</b> adc.h:156</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga5d3b8875947df2f4ba022cb6aa40594b"><div class="ttname"><a href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">adc_select_input</a></div><div class="ttdeci">static void adc_select_input(uint input)</div><div class="ttdoc">ADC input select.</div><div class="ttdef"><b>Definition:</b> adc.h:113</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga5d50a24eb26da7fbc6ee9bc76723b09c"><div class="ttname"><a href="group__hardware__adc.html#ga5d50a24eb26da7fbc6ee9bc76723b09c">adc_run</a></div><div class="ttdeci">static void adc_run(bool run)</div><div class="ttdoc">Enable or disable free-running sampling mode.</div><div class="ttdef"><b>Definition:</b> adc.h:184</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga61553375ecc9275fa14c6ff7792a1506"><div class="ttname"><a href="group__hardware__adc.html#ga61553375ecc9275fa14c6ff7792a1506">adc_fifo_get_blocking</a></div><div class="ttdeci">static uint16_t adc_fifo_get_blocking(void)</div><div class="ttdoc">Wait for the ADC FIFO to have data.</div><div class="ttdef"><b>Definition:</b> adc.h:277</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga689d64744e7fe5284562569b24e9d624"><div class="ttname"><a href="group__hardware__adc.html#ga689d64744e7fe5284562569b24e9d624">adc_fifo_get</a></div><div class="ttdeci">static uint16_t adc_fifo_get(void)</div><div class="ttdoc">Get ADC result from FIFO.</div><div class="ttdef"><b>Definition:</b> adc.h:268</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga84b5f9054de9c00d51095c9bdefb2dca"><div class="ttname"><a href="group__hardware__adc.html#ga84b5f9054de9c00d51095c9bdefb2dca">adc_get_selected_input</a></div><div class="ttdeci">static uint adc_get_selected_input(void)</div><div class="ttdoc">Get the currently selected ADC input channel.</div><div class="ttdef"><b>Definition:</b> adc.h:132</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gab15d6e804715935b4e9b5027a2940910"><div class="ttname"><a href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">adc_gpio_init</a></div><div class="ttdeci">static void adc_gpio_init(uint gpio)</div><div class="ttdoc">Initialise the gpio for use as an ADC pin.</div><div class="ttdef"><b>Definition:</b> adc.h:90</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gad637d97583f2c24e4159dc22bf17eaf2"><div class="ttname"><a href="group__hardware__adc.html#gad637d97583f2c24e4159dc22bf17eaf2">adc_fifo_drain</a></div><div class="ttdeci">static void adc_fifo_drain(void)</div><div class="ttdoc">Drain the ADC FIFO.</div><div class="ttdef"><b>Definition:</b> adc.h:288</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gaf32d82a43103e6672048001f58d5f6fb"><div class="ttname"><a href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">adc_read</a></div><div class="ttdeci">static uint16_t adc_read(void)</div><div class="ttdoc">Perform a single conversion.</div><div class="ttdef"><b>Definition:</b> adc.h:170</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gaf8e363e63f40e00c169f7355c9668681"><div class="ttname"><a href="group__hardware__adc.html#gaf8e363e63f40e00c169f7355c9668681">adc_irq_set_enabled</a></div><div class="ttdeci">static void adc_irq_set_enabled(bool enabled)</div><div class="ttdoc">Enable/Disable ADC interrupts.</div><div class="ttdef"><b>Definition:</b> adc.h:301</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gafa9793deea59c5cbfea147e0e9d895c3"><div class="ttname"><a href="group__hardware__adc.html#gafa9793deea59c5cbfea147e0e9d895c3">adc_fifo_get_level</a></div><div class="ttdeci">static uint8_t adc_fifo_get_level(void)</div><div class="ttdoc">Get number of entries in the ADC FIFO.</div><div class="ttdef"><b>Definition:</b> adc.h:259</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gafdfd586e6c26ffe4759afaa3c3f95465"><div class="ttname"><a href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">adc_fifo_is_empty</a></div><div class="ttdeci">static bool adc_fifo_is_empty(void)</div><div class="ttdoc">Check FIFO empty state.</div><div class="ttdef"><b>Definition:</b> adc.h:243</div></div>
<div class="ttc" id="agroup__hardware__base_html_ga625e737a57f12211cf1f634ca5095ae4"><div class="ttname"><a href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a></div><div class="ttdeci">static __force_inline void hw_set_bits(io_rw_32 *addr, uint32_t mask)</div><div class="ttdoc">Atomically set the specified bits to 1 in a HW register.</div><div class="ttdef"><b>Definition:</b> address_mapped.h:135</div></div>
<div class="ttc" id="agroup__hardware__base_html_ga81b27e30abef56fe090d22fd8dfdbcc1"><div class="ttname"><a href="group__hardware__base.html#ga81b27e30abef56fe090d22fd8dfdbcc1">hw_write_masked</a></div><div class="ttdeci">static __force_inline void hw_write_masked(io_rw_32 *addr, uint32_t values, uint32_t write_mask)</div><div class="ttdoc">Set new values for a sub-set of the bits in a HW register.</div><div class="ttdef"><b>Definition:</b> address_mapped.h:171</div></div>
<div class="ttc" id="agroup__hardware__base_html_gafd1c089df868d987daf95870b501c2ed"><div class="ttname"><a href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a></div><div class="ttdeci">static __force_inline void hw_clear_bits(io_rw_32 *addr, uint32_t mask)</div><div class="ttdoc">Atomically clear the specified bits to 0 in a HW register.</div><div class="ttdef"><b>Definition:</b> address_mapped.h:145</div></div>
<div class="ttc" id="agroup__hardware__gpio_html_ga22f6b90c4c7e0013b4b5341de0a44fc4"><div class="ttname"><a href="group__hardware__gpio.html#ga22f6b90c4c7e0013b4b5341de0a44fc4">gpio_set_function</a></div><div class="ttdeci">void gpio_set_function(uint gpio, gpio_function_t fn)</div><div class="ttdoc">Select GPIO function.</div><div class="ttdef"><b>Definition:</b> gpio.c:38</div></div>
<div class="ttc" id="agroup__hardware__gpio_html_ga74a8c3e55185581bc3df335aea1d0fb8"><div class="ttname"><a href="group__hardware__gpio.html#ga74a8c3e55185581bc3df335aea1d0fb8">gpio_set_input_enabled</a></div><div class="ttdeci">void gpio_set_input_enabled(uint gpio, bool enabled)</div><div class="ttdoc">Enable GPIO input.</div><div class="ttdef"><b>Definition:</b> gpio.c:273</div></div>
<div class="ttc" id="agroup__hardware__gpio_html_gae57a625b7e0bcac6d596f35864ffc792"><div class="ttname"><a href="group__hardware__gpio.html#gae57a625b7e0bcac6d596f35864ffc792">gpio_disable_pulls</a></div><div class="ttdeci">static void gpio_disable_pulls(uint gpio)</div><div class="ttdoc">Disable pulls on specified GPIO.</div><div class="ttdef"><b>Definition:</b> gpio.h:337</div></div>
<div class="ttc" id="agroup__hardware__gpio_html_ggaf91b38a4d4e96c343bd16927c34936e0a3ec115257e1f1747abf60284362c5a04"><div class="ttname"><a href="group__hardware__gpio.html#ggaf91b38a4d4e96c343bd16927c34936e0a3ec115257e1f1747abf60284362c5a04">GPIO_FUNC_NULL</a></div><div class="ttdeci">@ GPIO_FUNC_NULL</div><div class="ttdoc">Select NULL as GPIO pin function.</div><div class="ttdef"><b>Definition:</b> io_bank0.h:41</div></div>
<div class="ttc" id="agroup__pico__platform_html_gab0d1ba75ceb64131e19f613d7a5313c9"><div class="ttname"><a href="group__pico__platform.html#gab0d1ba75ceb64131e19f613d7a5313c9">tight_loop_contents</a></div><div class="ttdeci">static __force_inline void tight_loop_contents(void)</div><div class="ttdoc">No-op function for the body of tight loops.</div><div class="ttdef"><b>Definition:</b> platform.h:67</div></div>
<div class="ttc" id="apico_8h_html"><div class="ttname"><a href="pico_8h.html">pico.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>